import os

dirs = 'mipmap-hdpi', 'mipmap-mdpi', 'mipmap-xhdpi', 'mipmap-xxhdpi', 'mipmap-xxxhdpi'
file_name_dict = {}
for kv in open("data.txt", mode="rb").read().decode().split("\n"):
    arr = kv.split("=")
    print(arr)
    file_name_dict[arr[0]] = arr[1].strip("\r")
print(file_name_dict)
# noinspection PyInterpreter
for dirname in dirs:
    path = os.path.join(os.getcwd(), dirname)
    if os.path.isdir(path):
        for filename in os.listdir(path):
            fileArr=filename.split(".")
            temName=fileArr[0]
            suffix=fileArr[1]
            if temName in file_name_dict.keys():
                # # print(dirname, filename, "->", file_name_dict[filename])
                os.rename(src=os.getcwd() + "\\" + dirname + "\\" + filename,
                          dst=os.getcwd() + "\\" + dirname + "\\" + file_name_dict[temName]+"."+suffix)
file = open( "data.txt", "w+" )     # 文件如果不存在就创建
file.truncate()
file.close()